package com.one.group.user.lister;

import com.one.group.user.service.CellCacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class CellCacheListener {
    @Autowired
    private CellCacheService cellCacheService;

    @RabbitListener(bindings = @QueueBinding(value = @Queue(name = "cell.cache"),
            exchange = @Exchange(name = "gxa.direct"), key = {"cellUpdate"}))
    public void listenerUpdateMessage(Long tenantId) {
        log.info("监听到删除缓存消息,删除缓存:{}",tenantId);
        //删除小区缓存
        cellCacheService.deleteCellCache(tenantId);
    }
}
